<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<h:head>
</h:head>

<ui:composition template="/template/template.xhtml">
	<ui:define name="corpo">
		<h:form id="formCadastrarTurma">

			<br />
			<br />
			<div id="lado">


				<h2>Atualizar Turma</h2>

				<div id="confirma"></div>



				<div id="div">

					<div id="erros">
						<p:messages />

					</div>

					<p:fieldset legend="Dados da Turma" toggleable="true">



						<br />

						<h:panelGrid columns="4">
							<h:outputLabel value="Nome da Turma*" />
							<p:inputText id="name" required="true"
								requiredMessage="Nome da Turma não informado*."
								value="#{turmaBean.turma.nome}" size="10" />

							<h:outputLabel value="Ano Letivo* " />
							<p:inputText id="anoLetivo" required="true"
								requiredMessage="Ano Letivo não informado*."
								value="#{turmaBean.turma.anoLetivo}" size="10" disabled="false">
							</p:inputText>
						</h:panelGrid>

						<h:panelGrid columns="4">
							<h:outputLabel value="Nome da Sala*" />
							<p:inputText id="sala" required="true"
								requiredMessage="Nome da Sala não informado*."
								value="#{turmaBean.turma.sala}" size="10" />

							<h:outputLabel value="Quant. de Alunos*" />
							<p:inputText id="quantidadeAlunos" required="true"
								requiredMessage="Quant. de Alunos não informado*."
								value="#{turmaBean.turma.quantidadeAlunos}" size="10" />


						</h:panelGrid>

						<h:panelGrid columns="8">
							<h:outputLabel value="Turno* " />
							<h:selectOneMenu id="turno" required="true"
								requiredMessage="Turno não informado*."
								value="#{turmaBean.turma.turno}">
								<f:selectItem itemLabel=":: Selecione ::"
									noSelectionOption="true" />
								<f:selectItem itemLabel="Matutino" itemValue="MATUTINO" />
								<f:selectItem itemLabel="Vespertino" itemValue="VESPERTINO" />
								<f:selectItem itemLabel="Noturno" itemValue="NOTURNO" />
							</h:selectOneMenu>


							<h:outputLabel value="Modalidade* " />
							<h:selectOneMenu id="modalidade" required="true"
								requiredMessage="Modalidade não informado*."
								value="#{turmaBean.turma.modalidade}"
								converter="genericConverter">
								<f:selectItem itemLabel=":: Selecione ::"
									noSelectionOption="true" />
								<f:selectItems value="#{modalidadeBean.modalidades}"
									var="modalidade" itemLabel="#{modalidade.nome}"
									itemValue="#{modalidade}" />
							</h:selectOneMenu>
							</h:panelGrid>
							
							<h:panelGrid columns="8">
							<h:outputLabel value="Etapa/Série*" />
							<h:selectOneMenu id="etapaSerie" required="true"
								requiredMessage="Etapa/Série não informado*."
								value="#{turmaBean.turma.etapaSerie}"
								converter="genericConverter">
								<f:selectItem itemLabel=":: Selecione ::"
									noSelectionOption="true" />
								<f:selectItems value="#{etapaSerieBean.etapaseries}"
									var="etapaserie" itemLabel="#{etapaserie.nome}"
									itemValue="#{etapaserie}" />

								<p:ajax event="change" update="disciplinaTurmas"
									actionListener="#{turmaBean.carregarDisciplinaTurma}" />
							</h:selectOneMenu>
						</h:panelGrid>


						<br />

						<p:dataTable id="disciplinaTurmas"
							value="#{turmaBean.turma.disciplinaTurmas}" var="disciplinaTurma">

							<p:column headerText="Disciplina">
								<h:outputText value="#{disciplinaTurma.disciplina.nome}" />
							</p:column>

							<p:column headerText="Professor">
								<h:outputText id="professor"
									value="#{disciplinaTurma.professor.nomeCompleto}" rules="rows"
									size="30" readonly="true" disabled="true"
									styleClass="textoBlackBold" />

								<h:outputText id="name"
									value="#{disciplinaTurma.professor.nomeCompleto}"
									rendered="#{not empty pprBean.firstname}" />

							</p:column>

							<p:column style="width:20px" headerText="Operações">
								<p:commandButton update=":form:display"
									oncomplete="dlgProfessores.show()"
									image="ui-icon ui-icon-pencil" title="Vincular Professor">
									<f:setPropertyActionListener value="#{disciplinaTurma}"
										target="#{turmaBean.disciplinaTurmaSelecionada}" />
								</p:commandButton>

							</p:column>
						</p:dataTable>

					</p:fieldset>
				</div>
			</div>

			<h:panelGrid columns="4">
				<p:commandButton id="btSalvar" value="Salvar"
					action="#{turmaBean.salvar}" update="@form" image="ui-icon ui-icon-disk" />
				<p:commandButton id="voltar" ajax="false" value="Voltar"
					action="/paginas/turma/listarTurma.xhtml" update="@form" image="ui-icon ui-icon-disk" />
			</h:panelGrid>

		</h:form>

		<p:dialog header="Professor" widgetVar="dlgProfessores" width="900"
			showEffect="clip" hideEffect="explode" onCloseUpdate="form1"
			resizable="true" modal="true" appendToBody="false">
			<h:form id="form1">


				<h:outputLabel value="Nome Completo: " />
				<h:inputText id="nomeCompleto" value="#{professorBean.nomeCompleto}" />
				<br />

				<h:outputLabel value="CPF: " />
				<h:inputText id="cpf" value="#{professorBean.cpf}" />
				<br />

				<p:commandButton value="Pesquisar"
					action="#{professorBean.getProfessoresByNome}" />

				<p:outputPanel id="professores_pesq">
					<p:dataTable id="professores" value="#{professorBean.professores}"
						var="professor">
						<p:focus />
						<p:column headerText="Código">
							<h:outputText value="#{professor.id}" />
						</p:column>

						<p:column headerText="Nome">
							<h:outputText value="#{professor.nomeCompleto}" />

						</p:column>

						<p:column headerText="CPF">
							<h:outputText value="#{professor.cpf}" />
						</p:column>



						<p:column headerText="Ações" styleClass="acoes">

							<p:commandButton value="Selecionar"
								update="disciplinaTurmas,formCadastrarTurma"
								oncomplete="dlgProfessores.hide();"
								actionListener="turmaBean.vincularProfessor">
								<f:setPropertyActionListener value="#{professor}"
									target="#{turmaBean.disciplinaTurmaSelecionada.professor}" />

							</p:commandButton>
						</p:column>



					</p:dataTable>
				</p:outputPanel>
				
				

			</h:form>
		</p:dialog>
		<br />
				<br />
				<br />
				<br />
	</ui:define>
</ui:composition>
</html>